#ifndef DATESET_H
#define DATESET_H

#include "myday.h"
#include "mydatetable.h"
#include "mycombobox.h"
#include "memberclass.h"

#include <QLabel>
#include <QPushButton>
#include <QCalendarWidget>
#include <QTableWidget>
#include <QWidget>
#include <QCheckBox>
#include <QStackedWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>

extern int MINI_WORKDAY_DAY;
extern int MINI_WORKDAY_NIGHT;
extern int MINI_HOLIDAY_DAY;
extern int MINI_HOLIDAY_NIGHT;
extern int MINI_SPECIALDAY_DAY;
extern int MINI_SPECIALDAY_NIGHT;

class DateSet : public QWidget
{
    Q_OBJECT
public:
    explicit DateSet(QWidget *parent = nullptr);
    DateSet(QWidget *parent, QStackedWidget * pStackWidget);

private:

    void initPrivateVariable(void);

    void initDateTable(void);

    template<class Type>
    void deleteBoxLayout(Type *t);

    void createSettingWidget(void);

    QLabel *createSettingLabel(QString text, QFont font);

    MyCombobox * createSettingComboBox(QFont font, int flag);

    void setTableAndLineLayout(void);

    void getScheduleMonth(void);

    void initDatesetDialog(QDialog *pDialog, QSize size, QString title);

    void initDialogComboBox(QDialog *pDialog);

    void initDialogPushbutton(QDialog *pDialog);

    MyCombobox *  createDialogComboBox(QDialog *pDialog, QPoint point, QSize size, QList<QString> stringlist);

    void createDialogLabel(QDialog *pDialog, QPoint point, QSize size,QString text, QFont font);

    QPushButton * createDialogPushButton(QDialog *pDialog, QPoint point, QSize size,QString text);

    void connectDialogComboboxSignal(MyCombobox * pYear, MyCombobox * pMonth);

    void connectDialogPushButtonSignal(QPushButton * pYes, QPushButton * pCancel);

    void paintCalenderInDateTable(int yearIndex, int monthIndex);

    void CalcPosFromTheDay(QList<myDay*> & mydayList, int year, int month);

    void setMemberNoHolidayWork(myDay* & pDay);

    void initDateSetPushButton(void);

    void deinitMyDayList(QList<myDay*> & myDayList);

    void changeMyDayType(int row, int col, int dayType);

    void changeWorkActionDialog(void);

    void initDatesetWorkActionDialogPushButton(QDialog *pDialog);

    void initDatesetWorkActionDialogListWidget(QDialog *pDialog, QListWidget * &pList);

    void reloadDatesetWorkActionDialogListWidget(QListWidget * pList, QList<MemberClass*> memberlist);

    QCheckBox *createDatesetWorkActionDialogListWidgetCheckbox(QListWidget * pList, QString name);

signals:

public slots:
    void slot_dateSet_start(void);

private slots:
    void slot_btnRechoose_clicked(void);
    void slot_btnConfirm_clicked(void);
    void slot_btnReturn_clicked(void);
    void slot_changeDayAction_triggered(QPoint pos, int dayType);
    void slot_changeWorkAction_triggered(QPoint pos, int type);
    void slot_WorkActionDialogYesPushButton_clicked(QListWidget * pList, myDay * pMyDay);
    void slot_settingCombobox1_changed(int index);
    void slot_settingCombobox2_changed(int index);
    void slot_settingCombobox3_changed(int index);
    void slot_settingCombobox4_changed(int index);
    void slot_settingCombobox5_changed(int index);
    void slot_settingCombobox6_changed(int index);

private:
    bool bScheduleEnable;
    QWidget *myParent;
    QWidget *settingWidget;
    QStackedWidget * pStackWidget;
    QVBoxLayout *tableLayout;
    QGridLayout  *memberCountSettingLayout;
    QVBoxLayout *tableAndLabelLayout;
    QHBoxLayout *btnLayout;
    QVBoxLayout *widgetLayout;
    MyDateTable * pTable;
    QDialog *pGetScheduleMonthDialog;
    QDialog *pChangeWorkActionDialog;
    QDate *pDate;
    QListWidget * pChangeWorkActionDialogList;
    myDay* pWorkActionDialogTriggeredDay;        // 菜单右键改变工作选项时专用，用于dialog
    int iCurrentDialogYearComboBoxIndex;
    int iCurrentDialogMonthComboBoxIndex;
};

#endif // DATESET_H
